19. Exercise: Student Class

Student

Exercise: Student Class

Your goal in this lab is to write a class called Student that will hold data about a particular student. Your class simply needs to store the data and provide accessors and mutators.

Directions

  1. Add 3 private member variables to the class:
  • Name
  • Grade (e.g. 9th grade)
  • Grade Point Average
  1. Write a public constructor function to set the private attributes.
  2. Create public member functions to set each of the member variables. Before setting the values verify that:
  • Grade is from 0 (kindergarten) to 12
  • GPA is from 0.0 to 4.0
  • The function must either throw an exception if any of the invariants are violated
  1. Within the main() (outside of the class), declare an object of type Student and test out each of the member function calls.

Workspace

This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity, so you may be able to download them there.

Workspace Information:

  • Default file path:
  • Workspace type: jupyter
  • Opened files (when workspace is loaded): n/a